package cate.common.table.activity.hangdrop.shop;

import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

@NoteClass("掉落兑换活动-限购礼包 Row")
public class HangDropActivityShopRow extends ERow {
    @NoteField("分组")
    public int group;
    @NoteField("类型")
    public int type;
    @NoteField("奖励")
    public String rewardStr;
    @NoteField("限购次数")
    public int limit;
    @NoteField("碎钻购买")
    public String consumeStr;
    @NoteField("支付项")
    public int payId;
    @NoteField("每日刷新")
    public int dailyReset;

    @Override
    public void parse(XSSFRowWrap xrw) {
        super.parse(xrw);
        id = xrw.getInteger("ID");
        group = xrw.getInteger("分组");
        type = xrw.getInteger("类型");
        rewardStr = xrw.getString("奖励");
        limit = xrw.getInteger("限购次数", -1);
        consumeStr = xrw.getString("碎钻购买", "");
        payId = xrw.getInteger("支付项", 0);
        dailyReset = xrw.getInteger("每日刷新", 0);

        switch (type) {
            case 1: {
                if (consumeStr != null && !consumeStr.isEmpty()) {
                    getContext().warningOnSheetLoading(parent.parent.getFileName(),
                            parent.getSheetName(),
                            "ID=" + id + " 类型为免费,但是配置了物品消耗!");
                }
                if (payId != 0) {
                    getContext().warningOnSheetLoading(parent.parent.getFileName(),
                            parent.getSheetName(),
                            "ID=" + id + " 类型为免费,但是配置了支付项!");
                }
            }
            break;
            case 2: {
                if (consumeStr == null || consumeStr.isEmpty()) {
                    getContext().warningOnSheetLoading(parent.parent.getFileName(),
                            parent.getSheetName(),
                            "ID=" + id + " 类型为道具兑换,但是没有配置物品消耗!");
                }
                if (payId != 0) {
                    getContext().warningOnSheetLoading(parent.parent.getFileName(),
                            parent.getSheetName(),
                            "ID=" + id + " 类型为道具兑换,但是配置了支付项!");
                }
            }
            break;
            case 3: {
                if (consumeStr != null && !consumeStr.isEmpty()) {
                    getContext().warningOnSheetLoading(parent.parent.getFileName(),
                            parent.getSheetName(),
                            "ID=" + id + " 类型为支付购买,但是配置了物品消耗!");
                }
                if (payId == 0) {
                    getContext().warningOnSheetLoading(parent.parent.getFileName(),
                            parent.getSheetName(),
                            "ID=" + id + " 类型为支付购买,但是没有配置支付项!");
                }
            }
            break;
            default: {
                getContext().warningOnSheetLoading(parent.parent.getFileName(),
                        parent.getSheetName(),
                        "ID=" + id + " 类型配置错误! 不存在的类型!");
            }
            break;
        }

        if (rewardStr == null || rewardStr.isEmpty()) {
            getContext().warningOnSheetLoading(parent.parent.getFileName(),
                    parent.getSheetName(),
                    "ID=" + id + " 奖励为空!");
        }
    }
}
